import express from 'express'
import sqlQuery from '../utils/sql';
const router = express.Router()

router.get('/getCity', async (requset,reponese)=>{
    let res = await sqlQuery('select * from city')
    reponese.send(res)
})
router.get('/getStore',async (request,reponese)=>{
    let res = await sqlQuery('select * from store')
    reponese.send(res)
})

router.post('/searchStore',async (requset,reponese)=>{
    let {storename,city } = requset.body
    if(storename === undefined){
        storename = ''
    }
    console.log(storename,city);
    let res = await sqlQuery(`select * from store where store like "%${storename}%" and city = "${city}" `)
    reponese.send(res)
})
module.exports = router